# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=gst-plugins-base
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.26.1
pkgrel=4
pkgdesc="GStreamer Multimedia Framework Base Plugins (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://gstreamer.freedesktop.org/"
license=("spdx:LGPL-2.1-or-later")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-pkgconf"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc")
depends=("${MINGW_PACKAGE_PREFIX}-graphene"
         "${MINGW_PACKAGE_PREFIX}-gstreamer"
         "${MINGW_PACKAGE_PREFIX}-libogg"
         "${MINGW_PACKAGE_PREFIX}-libtheora"
         "${MINGW_PACKAGE_PREFIX}-libvorbis"
         "${MINGW_PACKAGE_PREFIX}-libpng"
         "${MINGW_PACKAGE_PREFIX}-libjpeg"
         "${MINGW_PACKAGE_PREFIX}-opus"
         "${MINGW_PACKAGE_PREFIX}-orc"
         "${MINGW_PACKAGE_PREFIX}-pango"
         "${MINGW_PACKAGE_PREFIX}-iso-codes"
         "${MINGW_PACKAGE_PREFIX}-zlib")
conflicts=("${MINGW_PACKAGE_PREFIX}-gst-plugins-bad<1.16.0")
source=("${url}/src/${_realname}/${_realname}-${pkgver}.tar.xz"{,.asc}
        0001-fix-gcc15-compiler-error.patch)
sha256sums=('659553636f84dcf388cad5cf6530e02b0b2d3dc450e76199287ba9db6a6c5226'
            'SKIP'
            '18d06e01acf7d4539eb9b0983de30b4d5c5b70d62421190aed3b2cd0dbb7702a')
validpgpkeys=('D637032E45B8C6585B9456565D2EEE6F6F349D7C') # Tim Müller <tim@gstreamer-foundation.org>

prepare() {
  cd "${_realname}-${pkgver}"

  # https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8904
  patch -p1 -i "${srcdir}"/0001-fix-gcc15-compiler-error.patch
}

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
  ${MINGW_PREFIX}/bin/meson.exe setup \
    --prefix="${MINGW_PREFIX}" \
    --buildtype plain \
    --wrap-mode=nofallback \
    -Dauto_features=enabled \
    -Dpackage-origin='https://www.msys2.org' \
    -Dtests=disabled \
    -Dexamples=disabled \
    -Dx11=disabled \
    -Dxi=disabled \
    -Dxshm=disabled \
    -Dxvideo=disabled \
    -Dalsa=disabled \
    -Dcdparanoia=disabled \
    -Dlibvisual=disabled \
    -Dtremor=disabled \
    -Ddoc=disabled \
    -Dgl_winsys=win32 \
    -Dgl_api=opengl \
    -Dgl_platform=wgl \
    -Ddrm=disabled \
    ../${_realname}-${pkgver}

  ${MINGW_PREFIX}/bin/meson.exe compile
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/meson.exe install

  rm -f "${pkgdir}"${MINGW_PREFIX}/lib/gstreamer*/*.a
}
